package com.qk.mapper;

import com.qk.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ActivityMapper {

    /**
     *  活动列表查询
     */
    List<Activity> selectList(Integer channel, Integer type, Integer status) ;

    /**
     *  添加活动
     */
    @Insert("insert into activity(channel,name,start_time,end_time,description,type,discount,voucher,create_time,update_time) " +
            "values(#{channel},#{name},#{startTime},#{endTime},#{description},#{type},#{discount},#{voucher}," +
            "#{createTime},#{updateTime})")
    void insert(Activity activity);

    /**
     *  根据id查询活动
     */
    @Select("select * from activity where id=#{id}")
    Activity selectById(Integer id);

    /**
     *  删除活动
     */
    @Delete("delete from activity where id= #{id}")
    void deleteById(Integer id);

    /**
     *  更新活动
     */
//    @Update("update activity set channel=#{channel},name=#{name},start_time=#{startTime},end_time=#{endTime}," +
//            "description=#{description},type=#{type},discount=#{discount},voucher=#{voucher}," +
//            "update_time=#{updateTime} where id =#{id}" )
    void update(Activity activity);

    /**
     *  根据活动类型查询活动
     */
    @Select("select * from activity where type= #{type}")
    List<Activity> selectByType(Integer type);

    /**
     * 查询所有活动
     */
    @Select("select * from activity")
    List<Activity> selectAll();
}
